Set torn off menus to be transient for the toplevel they were torn off
authorMatthias Clasen <maclas@gmx.de>
Wed, 5 Nov 2003 21:50:51 +0000 (21:50 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Wed, 5 Nov 2003 21:50:51 +0000 (21:50 +0000)
Wed Nov  5 22:49:36 2003  Matthias Clasen  <maclas@gmx.de>

* gtk/gtkmenu.c (gtk_menu_set_tearoff_state): Set torn off
menus to be transient for the toplevel they were torn off from.
(gtk_menu_get_toplevel): Auxiliary function to find the
toplevel of a menu.  (#54775, Jon-Kare Hellan)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkmenu.c

index f64e294c6a36d720906a85ca7cef088e962338ea..acf46e6afa2252ce0c1f568ec2f59d64548d3787 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Nov  5 22:49:36 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkmenu.c (gtk_menu_set_tearoff_state): Set torn off 
+       menus to be transient for the toplevel they were torn off from.
+       (gtk_menu_get_toplevel): Auxiliary function to find the
+       toplevel of a menu.  (#54775, Jon-Kare Hellan)
+
 Wed Nov  5 21:07:58 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkpaned.c (gtk_paned_class_init): Add readonly properties
index f64e294c6a36d720906a85ca7cef088e962338ea..acf46e6afa2252ce0c1f568ec2f59d64548d3787 100644 (file)
@@ -1,3 +1,10 @@
+Wed Nov  5 22:49:36 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkmenu.c (gtk_menu_set_tearoff_state): Set torn off 
+       menus to be transient for the toplevel they were torn off from.
+       (gtk_menu_get_toplevel): Auxiliary function to find the
+       toplevel of a menu.  (#54775, Jon-Kare Hellan)
+
 Wed Nov  5 21:07:58 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkpaned.c (gtk_paned_class_init): Add readonly properties
index f64e294c6a36d720906a85ca7cef088e962338ea..acf46e6afa2252ce0c1f568ec2f59d64548d3787 100644 (file)
@@ -1,3 +1,10 @@
+Wed Nov  5 22:49:36 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkmenu.c (gtk_menu_set_tearoff_state): Set torn off 
+       menus to be transient for the toplevel they were torn off from.
+       (gtk_menu_get_toplevel): Auxiliary function to find the
+       toplevel of a menu.  (#54775, Jon-Kare Hellan)
+
 Wed Nov  5 21:07:58 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkpaned.c (gtk_paned_class_init): Add readonly properties
index f64e294c6a36d720906a85ca7cef088e962338ea..acf46e6afa2252ce0c1f568ec2f59d64548d3787 100644 (file)
@@ -1,3 +1,10 @@
+Wed Nov  5 22:49:36 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkmenu.c (gtk_menu_set_tearoff_state): Set torn off 
+       menus to be transient for the toplevel they were torn off from.
+       (gtk_menu_get_toplevel): Auxiliary function to find the
+       toplevel of a menu.  (#54775, Jon-Kare Hellan)
+
 Wed Nov  5 21:07:58 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkpaned.c (gtk_paned_class_init): Add readonly properties
index f64e294c6a36d720906a85ca7cef088e962338ea..acf46e6afa2252ce0c1f568ec2f59d64548d3787 100644 (file)
@@ -1,3 +1,10 @@
+Wed Nov  5 22:49:36 2003  Matthias Clasen  <maclas@gmx.de>
+
+       * gtk/gtkmenu.c (gtk_menu_set_tearoff_state): Set torn off 
+       menus to be transient for the toplevel they were torn off from.
+       (gtk_menu_get_toplevel): Auxiliary function to find the
+       toplevel of a menu.  (#54775, Jon-Kare Hellan)
+
 Wed Nov  5 21:07:58 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkpaned.c (gtk_paned_class_init): Add readonly properties
index 0c0277a720a11abddf22a54298b3d9b473fd56c9..ee96ad2d22d733e17e8607823e8f981d2e26938d 100644 (file)
@@ -1554,6 +1554,28 @@ gtk_menu_update_title (GtkMenu *menu)
     }
 }
 
+static GtkWidget*
+gtk_menu_get_toplevel (GtkWidget *menu)
+{
+  GtkWidget *attach, *toplevel;
+
+  attach = gtk_menu_get_attach_widget (GTK_MENU (menu));
+
+  if (GTK_IS_MENU_ITEM (attach))
+    attach = attach->parent;
+
+  if (GTK_IS_MENU (attach))
+    return gtk_menu_get_toplevel (attach->parent);
+  else if (GTK_IS_WIDGET (attach))
+    {
+      toplevel = gtk_widget_get_toplevel (attach->parent);
+      if (GTK_WIDGET_TOPLEVEL (toplevel)) 
+       return toplevel;
+    }
+
+  return NULL;
+}
+
 void       
 gtk_menu_set_tearoff_state (GtkMenu  *menu,
                            gboolean  torn_off)
@@ -1574,12 +1596,15 @@ gtk_menu_set_tearoff_state (GtkMenu  *menu,
 
          if (!menu->tearoff_window)
            {
+             GtkWidget *toplevel;
+
              menu->tearoff_window = gtk_widget_new (GTK_TYPE_WINDOW,
                                                     "type", GTK_WINDOW_TOPLEVEL,
                                                     "screen", gtk_widget_get_screen (menu->toplevel),
                                                     "app_paintable", TRUE,
                                                     NULL);
 
+             
              gtk_window_set_type_hint (GTK_WINDOW (menu->tearoff_window),
                                        GDK_WINDOW_TYPE_HINT_MENU);
              gtk_window_set_mnemonic_modifier (GTK_WINDOW (menu->tearoff_window), 0);
@@ -1591,6 +1616,11 @@ gtk_menu_set_tearoff_state (GtkMenu  *menu,
              gtk_menu_update_title (menu);
 
              gtk_widget_realize (menu->tearoff_window);
+
+             toplevel = gtk_menu_get_toplevel (GTK_WIDGET (menu));
+             if (toplevel != NULL)
+               gtk_window_set_transient_for (GTK_WINDOW (menu->tearoff_window),
+                                             GTK_WINDOW (toplevel));
              
              menu->tearoff_hbox = gtk_hbox_new (FALSE, FALSE);
              gtk_container_add (GTK_CONTAINER (menu->tearoff_window), menu->tearoff_hbox);